<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<script>
//this什么时候出问题？
	//1.定时器-----再套一层,_this=this
	//2.事件
/*function aa(){
	this.a=12	
};
aa.prototype.show=function(){
	var _this=this;
	alert(this.a);	
	setInterval(function(){
		_this.show();	
	},1000)
};
var obj=new aa();
obj.show();

*/

function bb(){
	var _this=this;
	this.b=5;
	document.getElementById('btn').onclick=function(){
		 _this.show();	
	}	
};


bb.prototype.show=function(){
	alert(this.b)	
};
window.onload=function(){
	new bb();	
};






</script>

<input id='btn' type="button" value="按钮" />
</body>
</html>
